package com.sky.utils;

public class CurrentHolder {
    // 存储当前用户 ID，ThreadLocal 保证线程隔离
    private static final ThreadLocal<Long> CURRENT_LOCAL = new ThreadLocal<>();

    // 设置用户 ID 到 ThreadLocal
    public static void setCurrentId(Long employeeId) {
        CURRENT_LOCAL.set(employeeId);
    }

    // 获取用户 ID
    public static Long getCurrentId() {
        return CURRENT_LOCAL.get();
    }

    // 移除用户 ID，防止内存泄漏（建议在请求结束时调用）
    public static void remove() {
        CURRENT_LOCAL.remove();
    }
}
